﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jzy.Core.Utility;
using ECommerce.BLL.Order;
using ECommerce.Model.Order;

namespace ECommerce.Web.Site
{
    public partial class PayInterface : SitePage
    {
        private long OrderID
        {
            get
            {
                return long.Parse(StrUtil.DecryptUrl(Request.QueryString["OrderID"]));
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            base.CheckLogin();
            if (!IsPostBack)
            {
                ECOrderBO order = new ECOrderBO();
                ECOrderInfo info = order.GetInfo(OrderID);
                litAmount.Text = (info.TradeValue + info.Freight).ToString("c2");
                if (info.LogisticsType == (int)LogisticType.门店自取)
                {
                    this.h.Visible = false; 
                }
            }
        }

        protected void btnNext_Click(object sender, EventArgs e)
        {
            string tag = Request.Form["interface"];
            if ( tag == "0")
            {
                Response.Redirect("Send.aspx?OrderID=" + StrUtil.EncryptUrl(OrderID));
            }
            else if (tag == "1")
            {
                Response.Redirect("../Alipay/Send.aspx?OrderID=" + StrUtil.EncryptUrl(OrderID));

            }
            else
            {
                ECOrderBO order = new ECOrderBO();
                ECOrderInfo info = order.GetInfo(this.OrderID);
                info.PayMode = (int)PayMode.货到付款;
                order.Save(info);

                Response.Redirect("Shopping3.aspx", true);
            }

        }
    }
}